class Solution {
public:
    vector<int> resultsArray(vector<vector<int>>& queries, int k) {
        vector<int> ret(queries.size());
        priority_queue<int> pq;
        for (int i = 0; i < queries.size(); i++)
        {
            int dist = abs(queries[i][0]) + abs(queries[i][1]);
            if (pq.size() == k)
            {
                if (dist < pq.top())
                {
                    pq.pop();
                    pq.push(dist);
                }
                ret[i] = pq.top();
            }
            else
            {
                pq.push(dist);
                if (pq.size() == k)
                    ret[i] = pq.top();
                else
                    ret[i] = -1;
            }
        }
        return ret;
    }
};